package com.carpark.ejb.Model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Krzysztof
 */
@Entity
@Table(name = "clients")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ClientsModel.findAll", query = "SELECT c FROM ClientsModel c"),
    @NamedQuery(name = "ClientsModel.findByClientId", query = "SELECT c FROM ClientsModel c WHERE c.clientId = :clientId"),
    @NamedQuery(name = "ClientsModel.findByName", query = "SELECT c FROM ClientsModel c WHERE c.name = :name"),
    @NamedQuery(name = "ClientsModel.findByLastName", query = "SELECT c FROM ClientsModel c WHERE c.lastName = :lastName"),
    @NamedQuery(name = "ClientsModel.findByCity", query = "SELECT c FROM ClientsModel c WHERE c.city = :city"),
    @NamedQuery(name = "ClientsModel.findByZipCode", query = "SELECT c FROM ClientsModel c WHERE c.zipCode = :zipCode"),
    @NamedQuery(name = "ClientsModel.findByStreet", query = "SELECT c FROM ClientsModel c WHERE c.street = :street"),
    @NamedQuery(name = "ClientsModel.findByHouseNumber", query = "SELECT c FROM ClientsModel c WHERE c.houseNumber = :houseNumber"),
    @NamedQuery(name = "ClientsModel.findByLocalNumber", query = "SELECT c FROM ClientsModel c WHERE c.localNumber = :localNumber"),
    @NamedQuery(name = "ClientsModel.findByNipNumber", query = "SELECT c FROM ClientsModel c WHERE c.nipNumber = :nipNumber"),
    @NamedQuery(name = "ClientsModel.findByPhone", query = "SELECT c FROM ClientsModel c WHERE c.phone = :phone"),
    @NamedQuery(name = "ClientsModel.findByEmail", query = "SELECT c FROM ClientsModel c WHERE c.email = :email"),
    @NamedQuery(name = "ClientsModel.findByPassword", query = "SELECT c FROM ClientsModel c WHERE c.password = :password"),
    @NamedQuery(name = "ClientsModel.findByComments", query = "SELECT c FROM ClientsModel c WHERE c.comments = :comments")})
public class ClientsModel implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ClientId")
    private Integer clientId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "LastName")
    private String lastName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "City")
    private String city;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "ZipCode")
    private String zipCode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Street")
    private String street;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "HouseNumber")
    private String houseNumber;
    @Column(name = "LocalNumber")
    private Integer localNumber;
    @Basic(optional = false)
    @Size(max = 13)
    @Column(name = "NipNumber")
    private String nipNumber;
    @Size(max = 12)
    @Column(name = "Phone")
    private String phone;
    @Size(max = 50)
    @Column(name = "Email")
    private String email;
    @Size(max = 255)
    @Column(name = "Password")
    private String password;
    @Size(max = 100)
    @Column(name = "Comments")
    private String comments;
    @Column(name = "Blocked")
    private Boolean blocked;

    public ClientsModel() {
    }

    public ClientsModel(Integer clientId) {
        this.clientId = clientId;
    }

    public ClientsModel(Integer clientId, String name, String lastName, String city, String zipCode, String street, String houseNumber, String nipNumber) {
        this.clientId = clientId;
        this.name = name;
        this.lastName = lastName;
        this.city = city;
        this.zipCode = zipCode;
        this.street = street;
        this.houseNumber = houseNumber;
        this.nipNumber = nipNumber;
    }

    public ClientsModel(Integer clientId, String name, String lastName, String city, String zipCode, String street, String houseNumber, String nipNumber, String email, String pass) {
        this.clientId = clientId;
        this.name = name;
        this.lastName = lastName;
        this.city = city;
        this.zipCode = zipCode;
        this.street = street;
        this.houseNumber = houseNumber;
        this.nipNumber = nipNumber;
        this.password = pass;
        this.email = email;
    }

    public ClientsModel(String name, String lastName, String city, String zipCode, String street, String houseNumber, String nipNumber) {

        this.name = name;
        this.lastName = lastName;
        this.city = city;
        this.zipCode = zipCode;
        this.street = street;
        this.houseNumber = houseNumber;
        this.nipNumber = nipNumber;
    }

    public ClientsModel(String name, String lastName, String city, String zipCode, String street, String houseNumber, String nipNumber, String email, String pass) {

        this.name = name;
        this.lastName = lastName;
        this.city = city;
        this.zipCode = zipCode;
        this.street = street;
        this.houseNumber = houseNumber;
        this.nipNumber = nipNumber;
        this.password = pass;
        this.email = email;
    }

    public ClientsModel(String name, String lastName, String city, String zipCode, String street, String houseNumber, Integer localNumber, String nipNumber, String phone, String email, String pass) {
        this.name = name;
        this.lastName = lastName;
        this.city = city;
        this.zipCode = zipCode;
        this.street = street;
        this.houseNumber = houseNumber;
        this.localNumber = localNumber;
        this.nipNumber = nipNumber;
        this.phone = phone;
        this.password = pass;
        this.email = email;
    }

    public ClientsModel(String name, String lastName, String city, String zipCode, String street, String houseNumber, Integer localNumber, String nipNumber, String phone, String email, String pass, Boolean blocked) {
        this.name = name;
        this.lastName = lastName;
        this.city = city;
        this.zipCode = zipCode;
        this.street = street;
        this.houseNumber = houseNumber;
        this.localNumber = localNumber;
        this.nipNumber = nipNumber;
        this.phone = phone;
        this.password = pass;
        this.email = email;
        this.blocked = blocked;
    }

    public Integer getClientId() {
        return clientId;
    }

    public void setClientId(Integer clientId) {
        this.clientId = clientId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getHouseNumber() {
        return houseNumber;
    }

    public void setHouseNumber(String houseNumber) {
        this.houseNumber = houseNumber;
    }

    public Integer getLocalNumber() {
        return localNumber;
    }

    public void setLocalNumber(Integer localNumber) {
        this.localNumber = localNumber;
    }

    public String getNipNumber() {
        return nipNumber;
    }

    public void setNipNumber(String nipNumber) {
        this.nipNumber = nipNumber;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public Boolean getBlocked() {
        return blocked;
    }

    public void setBlocked(Boolean blocked) {
        this.blocked = blocked;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (clientId != null ? clientId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ClientsModel)) {
            return false;
        }
        ClientsModel other = (ClientsModel) object;
        if ((this.clientId == null && other.clientId != null) || (this.clientId != null && !this.clientId.equals(other.clientId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.carpark.ejb.Model.ClientsModel[ clientId=" + clientId + " ]";
    }

    public Object[] renderAsRecord() {
        String nameAsRecord = this.name != null ? this.name : "";
        String lastNameAsRecord = this.lastName != null ? this.lastName : "";
        String streetAsRecord = this.street != null ? this.street : "";
        String houseNumberAsRecord = this.houseNumber != null ? this.houseNumber : "";
        String localNumberAsRecord = this.localNumber != null ? this.localNumber.toString() : "";
        String cityAsRecord = this.city != null ? this.city : "";
        String zipCodeAsRecord = this.zipCode != null ? this.zipCode : "";
        String nipNumberAsRecord = this.nipNumber != null ? this.nipNumber : "";
        String phoneAsRecord = this.phone != null ? this.phone : "";
        String emailAsRecord = this.email != null ? this.email : "";
        String commentsAsRecord = this.comments != null ? this.comments : "";

        Object[] record = {nameAsRecord, lastNameAsRecord, streetAsRecord, houseNumberAsRecord, localNumberAsRecord, cityAsRecord, zipCodeAsRecord, nipNumberAsRecord, phoneAsRecord, emailAsRecord, commentsAsRecord};
        return record;
    }
}
